package com.shuwen.gcdj.service.sys.log;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shuwen.gcdj.bean.sys.log.request.LogPageReq;
import com.shuwen.gcdj.bean.sys.log.response.LogResp;
import com.shuwen.gcdj.entity.Log;
import com.shuwen.gcdj.mapper.mysql.LogMapper;
import com.shuwen.gcdj.service.BaseService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :杨云山
 * @date : 2023/3/15 9:51
 */
@Service
@AllArgsConstructor
@Slf4j
public class LogService extends BaseService<LogMapper, Log> {

    private final LogMapper logMapper;

    public Page<LogResp> getPageLogList(LogPageReq req) {

        Page<LogResp> page = new Page<>(req.getPageNum(), req.getPageSize(), true);
        IPage<LogResp> allList = logMapper.getPageLogList(page,req);
        List<LogResp> res = allList.getRecords();
        Page<LogResp> resPage = new Page<>(page.getCurrent(), page.getSize(), page.getTotal());
        resPage.setRecords(res);
        return resPage;
    }
}
